package com.project.service.impl;

import java.util.List;

import com.project.entity.User;
import com.project.entity.UserExample;
import com.project.mapper.UserMapper;
import com.project.service.UserManage;

public class UserManageService implements UserManage {
	private UserMapper userMapper;
	

	public UserMapper getUserMapper() {
		return userMapper;
	}

	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}

	public void deleteById(Integer userId) {
		try{
			this.userMapper.deleteByPrimaryKey(userId);
		}catch(Exception e){
			System.out.println("用户数据删除操作有异常");
		}

	}

	public List<User> getAll(Integer start, Integer limit) {
		UserExample example = new UserExample();
		
		return this.userMapper.selectByExample(example);
	}

	public User getById(Integer userId) {
		
		return this.userMapper.selectByPrimaryKey(userId);
	}

	public void update(User user) {
		try{
			this.userMapper.updateUser(user);
		}catch(Exception e){
			System.out.println("用户数据修改操作有异常");
		}

	}

	public int changePass(String past, String password, String id) {
		// TODO Auto-generated method stub
		int i;
		try{
			i = this.userMapper.changePass(past, password, id);
		}catch(Exception e){
			i = -1;
			e.printStackTrace();
		}
		return i;
	}

}
